Skip to main content

Example - ERC20 Token

The ERC-20 token standard is a widespread and respected protocol in the cryptocurrency space. It provides a set of rules and functionalities for issuing tokens on the Ethereum blockchain, as well as all EVM blockchains. In the context of the Torus blockchain, this standard is crucial for ensuring compatibility and interoperability with a broad range of decentralized applications (dApps) and services within the Ethereum/EVM ecosystem.

Creating Your Own ERC-20 Token

In this tutorial, we'll guide you through the process of creating a standard ERC-20 Token on the Torus testnet. Should you wish to deploy your smart contract on the Torus mainnet, simply follow the same procedure, ensuring to select the Torus mainnet network instead of the testnet network.

Requirements

  • A modern web browser (e.g., Chrome)
  • Testnet TQF for gas expenses
  • A crypto browser wallet

1. Add Torus Testnet to your browser wallet

Copy the following values in your browser wallet to connect to the Torus Testnet:

PropertyValue
Network nameTorus Horn Testnet
RPC URLhttps://rpc.testnet.toruschain.com/
Chain ID8194
Currency SymboltTQF
Block explorer URLhttps://testnet.toruscan.com/

This is what it should look like:

"Torus Testnet Config"

2. Get testnet tTQF

Visit the Torus Testnet Faucet to request tTQF (testnet TQF) tokens.

4. Set characteristics of your ERC20

You can read about all the buttons and what they mean here.

5. Using RemixIDE

Once you have set the characteristics above, click "Open in Remix" in the top right corner.

This is what the Remix IDE interface looks like:

"Remix IDE"

On the left sidebar click on the "Files" tab to open the File Explorer pane.

"File Explorer tab"

Here you can see some already existing files and directories.

Right click on your contract (that was created using the wizard earlier), click rename, and pick a name that is more memorable.

In this example, we're changing the name from "contract-1816344b59.sol" to "my_token.sol":

"New contract name"

danger

Make sure to keep the .sol extension, otherwise, this won't work.

6. Compiling the smart contract

After everything above is done, on the left sidebar click on the "Solidity compiler" tab:

"Solidity Compiler"

It is also important to note that when deploying on Torus, it's crucial to set the EVM version to london.

To do that click on "Advanced Configuration", and then under the "EVM Version" dropdown menu, select "london":

"London"

danger

When using a Solidity compiler version above 0.8.19, ensure the EVM version is set to London to avoid errors.

For optimal results and compatibility, use the latest compiler version, currently 0.8.23, with the London EVM setting.

info

Versions starting from 0.8.20 use the PUSH0(0x5f) opcode, which is not compatible with chains other than Ethereum mainnet.

Check the compiler version and the selected contract.

The compiler version should be at least 0.8.9 because of the line pragma solidity ^0.8.9; in the smart contract.

Then, click the Compile my_token.sol button. If everything goes well, you will see a green check mark on the Compile button:

"Compiling"

7. Deploying the smart contract

Then, click on the "Deploy & run transactions" button on the left sidebar:

"Compiling"

Here, there are 3 important fields:

"Injected"

Choose "Injected Provider" under the "Environment" field.

If you have correctly added Torus Testnet to your browser wallet as outlined in Step 1, you should see "Custom (8194) network" as shown here:

"Injected Provider"

Then make sure the contract selected is correct.

If you have renamed the contract and followed all the other steps in this guide, you should see this directory:

"Correct Contract"

After you have completed the above steps, click "Deploy" and confirm the transaction in your browser wallet:

"Transaction"

That’s it! Your token contract is now deployed on Torus's Horn testnet!

If you would like to deploy this contract on Torus mainnet, repeat all the steps outlined above, but using the Torus mainnet in your browser wallet.